/* 全局样式 - 固定尺寸 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
}

body {
    background-color: #f5f7fa;
    overflow: hidden;
    height: 100vh;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

/* 主容器 - 固定高度 */
.chat-container {
    display: flex;
    height: calc(100vh - 120px); /* 减去顶部导航栏高度 */
    width: 1200px; /* 固定宽度 */
    margin: 0 auto;
    background: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    overflow: hidden;
}

/* 左侧导航栏 - 固定宽度 */
.left-sidebar {
    width: 240px;
    background: #2c3e50;
    color: #ecf0f1;
    padding: 20px 0;
    overflow-y: auto;
}

.left-sidebar h2 {
    padding: 0 20px 20px;
    font-size: 18px;
    border-bottom: 1px solid #34495e;
}

.nav-item {
    padding: 14px 20px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 14px;
    display: flex;
    align-items: center;
}

.nav-item:hover {
    background: #34495e;
}

.nav-item.active {
    background: #3498db;
    position: relative;
}

.nav-item.active::after {
    content: "";
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    width: 3px;
    background: #fff;
}

/* 中间联系人列表 - 固定宽度 */
.message-list {
    width: 300px;
    border-right: 1px solid #eaeaea;
    overflow-y: auto;
    background: #f8f9fa;
}

.message-item {
    display: flex;
    padding: 15px;
    border-bottom: 1px solid #eaeaea;
    cursor: pointer;
    transition: background 0.2s;
}

.message-item:hover {
    background: #eef2f5;
}

.avatar img {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 12px;
    border: 2px solid #eaeaea;
}

.content {
    flex: 1;
    min-width: 0;
}

.header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.username {
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.time {
    color: #95a5a6;
    font-size: 12px;
}

.preview {
    color: #7f8c8d;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 右侧聊天窗口 - 固定宽度 */
.chat-window {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fff;
}

.chat-header {
    padding: 15px 20px;
    border-bottom: 1px solid #eaeaea;
    display: flex;
    align-items: center;
    background: #f8f9fa;
}

.user-info {
    display: flex;
    align-items: center;
}

.user-info img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 12px;
    object-fit: cover;
    border: 2px solid #eaeaea;
}

.user-info span {
    font-weight: 600;
    color: #2c3e50;
    font-size: 16px;
}

/* 消息区域 - 固定高度 */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f5f7fa;
    background-image: linear-gradient(#e5e9ec 1px, transparent 1px);
    background-size: 100% 10px;
}

.send, .recv {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
}

.send {
    align-items: flex-end;
}

.recv {
    align-items: flex-start;
}

.msg {
    max-width: 60%;
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.5;
    position: relative;
    margin-top: 10px;
}

.send .msg {
    background: #3498db;
    color: white;
    border-top-right-radius: 0;
}

.recv .msg {
    background: white;
    color: #2c3e50;
    border-top-left-radius: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.send-time, .recv-time {
    font-size: 14px;
}

.time {
    font-size: 12px;
    color: #95a5a6;
    margin-top: 5px;
    display: block;
    text-align: right;
}

/* 输入区域 - 固定高度 */
.input-area {
    padding: 15px;
    border-top: 1px solid #eaeaea;
    display: flex;
    background: #f8f9fa;
    height: 120px;
}

textarea {
    flex: 1;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    resize: none;
    font-size: 14px;
    outline: none;
    transition: border 0.2s;
}

textarea:focus {
    border-color: #3498db;
}

button {
    background: #3498db;
    color: white;
    border: none;
    padding: 0 25px;
    border-radius: 6px;
    cursor: pointer;
    margin-left: 10px;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
}

button:hover {
    background: #2980b9;
}

/* 历史消息提示 */
.history-hint {
    color: #3498db;
    font-size: 14px;
    text-align: center;
    padding: 20px;
    margin: 20px 0;
    background: rgba(52, 152, 219, 0.1);
    border-radius: 6px;
}

/* 图片消息样式 */
.msg img {
    max-width: 100%;
    border-radius: 6px;
    display: block;
}

/* 新增未读消息小红点样式 */
.unread-badge {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    background-color: #e74c3c;
    border-radius: 50%;
}

/* 调整联系人项样式以容纳小红点 */
.message-item {
    position: relative; /* 为小红点定位做准备 */
    padding-right: 25px; /* 为小红点留出空间 */
}

/* 优化消息预览样式 */
.preview {
    color: #7f8c8d;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px; /* 限制预览消息宽度 */
}

.isSelected{
    color: skyblue;
}